/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.ds2.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.ds2.modelo.Producto;

/**
 *
 * @author Piter
 */
@Stateless
public class ProductoDao extends AbstractDao<Producto> implements ProductoDaoLocal {
    @PersistenceContext(unitName = "Farmacias-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ProductoDao() {
        super(Producto.class);
    }
    @Override
    public boolean findDuplicity(Producto product){
     Query q = em.createNamedQuery("Producto.findByNombre");
     q.setParameter("nombre", product.getClave());
     //q.setParameter("apellidoMaterno", product.getMarca());
     //q.setParameter("apellidoPaterno", product.getNombre());
     return !q.getResultList().isEmpty();
 } 

}
